package com.bigstar.lolen_e;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class HistoryDialog extends Dialog implements OnClickListener {
	String nick_name;
	String history;
	String name;
	Context context;
	boolean noti;
	String tip;
	String tip2;
	public HistoryDialog(Context context, String nick_name, String history) {
		super(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
		this.context = context;
		this.nick_name = nick_name;
		this.history = history;
		this.noti = true;
	}
	
	public HistoryDialog(Context context, String name, String nickname, String history, String tip, String tip2) {
		super(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
		this.context = context;
		this.name = name;
		this.nick_name = name+", "+nickname;
		this.history = history;
		this.tip = tip;
		this.tip2 = tip2;
		this.noti = false;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.history);
		TextView tv = (TextView) findViewById(R.id.his_name);
		tv.setText(nick_name);
		tv = (TextView) findViewById(R.id.his_text);
		tv.setText(history);
		Button b = (Button) findViewById(R.id.his_close);
		b.setOnClickListener(this);
		if(noti){
			LinearLayout layout = (LinearLayout)findViewById(R.id.btn_histip);
			layout.setVisibility(View.GONE);
			layout = (LinearLayout)findViewById(R.id.lay_tip);
			layout.setVisibility(View.GONE);
		}else{
			LinearLayout layout = (LinearLayout)findViewById(R.id.lay_tip);
			layout.setVisibility(View.GONE);
			tv = (TextView)findViewById(R.id.his_text);
			tv.setVisibility(View.VISIBLE);
			b = (Button) findViewById(R.id.btn_his);
			b.setOnClickListener(this);
			b = (Button) findViewById(R.id.btn_tip);
			b.setOnClickListener(this);
			tv = (TextView) findViewById(R.id.tip_0_name);
			tv.setText("Playing As "+name);
			tv = (TextView) findViewById(R.id.tip_0_txt);
			tv.setText(Html.fromHtml(tip));
			tv = (TextView) findViewById(R.id.tip_1_name);
			tv.setText("Playing Against "+name);
			tv = (TextView) findViewById(R.id.tip_1_txt);
			tv.setText(Html.fromHtml(tip2));
			b = (Button) findViewById(R.id.btn_tip);
			b.setText("Tips");
		}
	}

	@Override
	public void onClick(View v) {
		if(v.getId() == R.id.his_close){
			this.dismiss();	
		}else if(v.getId() == R.id.btn_his){
			LinearLayout layout = (LinearLayout)findViewById(R.id.lay_tip);
			layout.setVisibility(View.GONE);
			TextView tv = (TextView)findViewById(R.id.his_text);
			tv.setVisibility(View.VISIBLE);
		}else if(v.getId() == R.id.btn_tip){
			TextView tv = (TextView)findViewById(R.id.his_text);
			tv.setVisibility(View.GONE);
			LinearLayout layout = (LinearLayout)findViewById(R.id.lay_tip);
			layout.setVisibility(View.VISIBLE);
		//	tv = (TextView)findViewById(R.id.tip_1_txt);
		//	tv.setVisibility(View.VISIBLE);
		}
	}
}
